<?php

if (!@include_once("./incl/auth.inc.php"))
 include_once("../incl/auth.inc.php");
if ($AllowEdit && isset($_GET['save']) && isset($_POST['filename']))
{
 $text = stripslashes($_POST['myfile']);
 if (!is_valid_name(stripslashes($_POST['filename'])))
  print "<font color='#CC0000'>$StrFileInvalidName</font>";
 else if ($fp = @fopen ($home_directory.$path.stripslashes($_POST['filename']), "wb"))
 {
  fwrite($fp, $text);
  fclose($fp);
  print "<font color='#009900'>$StrSaveFileSuccess</font>";
 }
 else
  print "<font color='#CC0000'>$StrSaveFileFail</font>";
}
else if ($AllowEdit && isset($_GET['filename']))
{
//-----------------------------------------------------------------------------------------------------------
?>
<script>
// -------------------------------------------------------------------------------------------------------------- //
function openPopUp(name,component,theme){
	if( navigator.appName != "Netscape"){
    NewWindow=window.open("<?="$path/$appname";?>/popup/component/"+component+"/"+name+".php?theme="+theme,"","' scrollbar='auto', resizable=1,top=0,left=760, width=250, height=750, status=0, toolbar=0 '");
  }
  else{
    NewWindow=window.open("<?="$path/$appname";?>/popup/component/"+component+"/"+name+".php?theme="+theme,"","' scrollbar='auto', resizable=1,top=0,left=800, width=260, height=580, status=0, toolbar=0 '");
  }
	NewWindow.creator=self;
}
// -------------------------------------------------------------------------------------------------------------- //

function toolbar_inout (){
    if(document.getElementById('toolbar').style.display !='none'){
    document.getElementById('toolbar').style.display='none';
    }
    else{
    document.getElementById('toolbar').style.display='inline';
    }
}
// -------------------------------------------------------------------------------------------------------------- //
function run_program(namefile){
	if( navigator.appName != "Netscape"){
    NewWindow=window.open(namefile,"","' scrollbar='auto', resizable=1,top=0,left=760, fullscreen=yes, width=550, height=550, status=0, toolbar=0, location=no '");
  }
  else{
    NewWindow=window.open(namefile,"","' scrollbar='auto', resizable=1,top=0,left=800, fullscreen=yes, width=550, height=550, status=0, toolbar=0, location=no '");
  }
	NewWindow.creator=self;
}
// -------------------------------------------------------------------------------------------------------------- //
</script>

<script type="text/javascript" src="../../../js/tabs/tabpane.js"></script>
<link type="text/css" rel="StyleSheet" href="../../../js/tabs/tabpane.css" />

<div class='table'>
  <p>
  <fieldset id='toolbar' >
  <legend> COMPONENT TOOLBAR </legend>
  <br>

<div class="tab-pane" id="tab-pane-1">

   <div class="tab-page">
      <h2 class="tab">Standard</h2>

    <?php
/*      //popup icons link autoload
      $component="standard";
      $i=0;
      $fd=opendir("popup/component/standard/");
      while (false !== ($nf= readdir($fd))){
          if (substr($nf,-4)==".php" && substr($nf, -10) !="dialog.php")
            $popups[$i++]=$nf;
      }
      closedir($fd);
      if ($i>0){
	    sort($popups);
	    foreach($popups as $popup){
		$popup=substr($popup,0,-4);
		echo"<acronym title='".substr($popup,3)."'>
		<input type='image' src='popup/images/component/standard/$popup.png' border=0 onClick=\"openPopUp('$popup','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">Additional</h2>

    <?php
/*      //popup icons link autoload
      $component="additional";
      $i=0;
      $fd_additional=opendir("$path/$appname/popup/component/additional/");
      while (false !== ($nf_additional= readdir($fd_additional))){
          if (substr($nf_additional, 3, 3) =="add")
            $popups_additional[$i++]=$nf_additional;
      }
      closedir($fd_additional);
      if ($i>0){
	    sort($popups_additional);
	    foreach($popups_additional as $popup_additional){
		$popup_additional=substr($popup_additional,0,-4);
		echo"<acronym title='".substr($popup_additional,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/additional/$popup_additional.png' border=0 onClick=\"openPopUp('$popup_additional','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">X-Win32</h2>

    <?php
/*      //popup icons link autoload
      $component="xwin32";
      $i=0;
      $fd_xwin32=opendir("$path/$appname/popup/component/xwin32/");
      while (false !== ($nf_xwin32= readdir($fd_xwin32))){
          if (substr($nf_xwin32, 3, 6) =="xwin32")
            $popups_xwin32[$i++]=$nf_xwin32;
      }
      closedir($fd_xwin32);
      if ($i>0){
	    sort($popups_xwin32);
	    foreach($popups_xwin32 as $popup_xwin32){
		$popup_xwin32=substr($popup_xwin32,0,-4);
		echo"<acronym title='".substr($popup_xwin32,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/xwin32/$popup_xwin32.png' border=0 onClick=\"openPopUp('$popup_xwin32','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>


   <div class="tab-page">
      <h2 class="tab">System</h2>

    <?php
/*      //popup icons link autoload
      $component="system";
      $i=0;
      $fd_system=opendir("$path/$appname/popup/component/system/");
      while (false !== ($nf_system= readdir($fd_system))){
          if (substr($nf_system, 3, 3) =="sys")
            $popups_system[$i++]=$nf_system;
      }
      closedir($fd_system);
      if ($i>0){
	    sort($popups_system);
	    foreach($popups_system as $popup_system){
		$popup_system=substr($popup_system,0,-4);
		echo"<acronym title='".substr($popup_system,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/system/$popup_system.png' border=0 onClick=\"openPopUp('$popup_system','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">Data Access</h2>

    <?php
/*      //popup icons link autoload
      $component="dataccess";
      $i=0;
      $fd_dataccess=opendir("$path/$appname/popup/component/dataccess/");
      while (false !== ($nf_dataccess= readdir($fd_dataccess))){
          if (substr($nf_dataccess, 3, 5) =="tdata")
            $popups_dataccess[$i++]=$nf_dataccess;
      }
      closedir($fd_dataccess);
      if ($i>0){
	    sort($popups_dataccess);
	    foreach($popups_dataccess as $popup_dataccess){
		$popup_dataccess=substr($popup_dataccess,0,-4);
		echo"<acronym title='".substr($popup_dataccess,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/dataccess/$popup_dataccess.png' border=0 onClick=\"openPopUp('$popup_dataccess','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">Data Controls</h2>

    <?php
/*      //popup icons link autoload
      $component="datacontrol";
      $i=0;
      $fd_datacontrol=opendir("$path/$appname/popup/component/datacontrol/");
      while (false !== ($nf_datacontrol= readdir($fd_datacontrol))){
          if (substr($nf_datacontrol, 3, 3) =="tdb")
            $popups_datacontrol[$i++]=$nf_datacontrol;
      }
      closedir($fd_datacontrol);
      if ($i>0){
	    sort($popups_datacontrol);
	    foreach($popups_datacontrol as $popup_datacontrol){
		$popup_datacontrol=substr($popup_datacontrol,0,-4);
		echo"<acronym title='".substr($popup_datacontrol,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/datacontrol/$popup_datacontrol.png' border=0 onClick=\"openPopUp('$popup_datacontrol','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">SQL Commands</h2>

    <hr />
   </div>


   <div class="tab-page">
      <h2 class="tab">Internet</h2>

    <?php
/*      //popup icons link autoload
      $component="internet";
      $i=0;
      $fd_internet=opendir("$path/$appname/popup/component/internet/");
      while (false !== ($nf_internet= readdir($fd_internet))){
          if (substr($nf_internet, 3, 5) =="thtml")
            $popups_internet[$i++]=$nf_internet;
      }
      closedir($fd_internet);
      if ($i>0){
	    sort($popups_internet);
	    foreach($popups_internet as $popup_internet){
		$popup_internet=substr($popup_internet,0,-4);
		echo"<acronym title='".substr($popup_internet,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/internet/$popup_internet.png' border=0 onClick=\"openPopUp('$popup_internet','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">XML</h2>

    <?php
/*      //popup icons link autoload
      $component="xml";
      $i=0;
      $fd_xml=opendir("$path/$appname/popup/component/xml/");
      while (false !== ($nf_xml= readdir($fd_xml))){
          if (substr($nf_xml, 3, 4) =="txml")
            $popups_xml[$i++]=$nf_xml;
      }
      closedir($fd_xml);
      if ($i>0){
	    sort($popups_xml);
	    foreach($popups_xml as $popup_xml){
		$popup_xml=substr($popup_xml,0,-4);
		echo"<acronym title='".substr($popup_xml,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/xml/$popup_xml.png' border=0 onClick=\"openPopUp('$popup_xml','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">Dialogs</h2>

    <?php
/*      //popup icons link autoload
      $component="dialogs";
      $i=0;
      $fd_dialog=opendir("$path/$appname/popup/component/dialogs/");
      while (false !== ($nf_dialog= readdir($fd_dialog))){
          if (substr($nf_dialog, -10) =="dialog.php")
            $popups_dialog[$i++]=$nf_dialog;
      }
      closedir($fd_dialog);
      if ($i>0){
	    sort($popups_dialog);
	    foreach($popups_dialog as $popup_dialog){
		$popup_dialog=substr($popup_dialog,0,-4);
		echo"<acronym title='".substr($popup_dialog,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/dialogs/$popup_dialog.png' border=0 onClick=\"openPopUp('$popup_dialog','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>

   <div class="tab-page">
      <h2 class="tab">Servers</h2>

    <?php
/*      //popup icons link autoload
      $component="server";
      $i=0;
      $fd_server=opendir("$path/$appname/popup/component/server/");
      while (false !== ($nf_server= readdir($fd_server))){
          if (substr($nf_server, -10) =="server.php")
            $popups_server[$i++]=$nf_server;
      }
      closedir($fd_server);
      if ($i>0){
	    sort($popups_server);
	    foreach($popups_server as $popup_server){
		$popup_server=substr($popup_server,0,-4);
		echo"<acronym title='".substr($popup_server,3)."'>
		<input type='image' src='$path/$appname/popup/images/component/server/$popup_server.png' border=0 onClick=\"openPopUp('$popup_server','$component','".theme()."'); \" />
		</acronym>
		";
	    }
	} */
    ?>

   </div>


</div>


  <br>
  <br>
  </fieldset>
<?
//-----------------------------------------------------------------------------------------------------------

echo "<script>document.getElementById('toolbar').style.display='none';</script>";

echo "<br><div class='tab-pane' id='tab-pane-2'>";

echo "<div class='tab-page' id='tab-code'>";
echo "<h2 class='tab' id='code'>CODE</h2>";
 print "<table class='index' width=98% cellpadding=0 cellspacing=0>";
  print "<tr>";
   print "<td class='iheadline' height=21>";
    print "<font class='iheadline'>&nbsp;$StrEditing \"".htmlentities($filename)."\"</font>";
   print "</td>";
   print "<td class='iheadline' align='right' height=21>";
//    print "<input type='image' src='_images/menu_view_forms.png' border=0 alt='Component ToolBar View (On/Off)' onclick='javascript:toolbar_inout();' /> ";
//    print "<input type='image' src='_images/menu_run.png' alt='Run Current Program' onclick='javascript:run_program($path/$filename);' />";
    print "<input type='image' src='_images/menu_search_find.png' alt='Search' onclick='javascript:run_search($path/$filename);' />";
    print " <input type='image' src='_images/menu_search_find_previous.png' alt='Search - Previous' onclick='javascript:run_search_previous($path/$filename);' />";
    print " <input type='image' src='_images/menu_search_find_next.png' alt='Search - Next' onclick='javascript:run_search_next($path/$filename);' />";
    print " <input type='image' src='_images/menu_search_replace.png' alt='Search & Replace' onclick='javascript:run_search_replace($path/$filename);' />";

    print "<font class='iheadline'><a href='$base_url&amp;path=".htmlentities(rawurlencode($path))."'><img src='icon/back.gif' border=0 alt='$StrBack'></a></font>";
   print "</td>";
  print "</tr>";
  print "<tr>";
   print "<td valign='top' colspan=2>";
   print "<center><br />";

$rest = substr($filename, -3);
// print $rest;
if ($rest == '.js' or $rest == '.JS') {$resto = 'javascript';}
if ($rest == 'php'  or $rest == 'PHP' or $rest == 'inc' or $rest == 'INC') {$resto = 'php';}
if ($rest == 'ava' or $rest == 'AVA') {$resto = 'java';}
if ($rest == 'erl'  or $rest == 'ERL' or $rest == '.pl' or $rest == '.PL' or $rest == 'cgi' or $rest == 'CGI') {$resto = 'perl';}
if ($rest == 'txt' or $rest == 'TXT' or $rest == 'dat' or $rest == 'DAT') {$resto = 'text';}
if ($rest == 'htm'  or $rest == 'HTM' or $rest == 'tml' or $rest == 'TML') {$resto = 'html';}
if ($rest == 'css' or $rest == 'CSS') {$resto = 'css';}
if ($rest == '.py' or $rest == '.PY') {$resto = 'pyton';}
if ($rest == '.rb' or $rest == '.RB') {$resto = 'ruby';}
if ($rest == 'cpp' or $rest == 'CPP') {$resto = 'cpp';}
if ($rest == 'pas' or $rest == 'PAS') {$resto = 'delphi';}
if ($rest == '.c#' or $rest == '.C#') {$resto = 'c#';}
   if ($fp = @fopen($home_directory.$path.$filename, "rb"))
   {
if (file_exists("../../../extras/codepress/codepress.php")) {
    print "<form action='$base_url&amp;output=editcode&amp;save=true' method='post'>";
print"<input type='hidden' name='myfile' value=''>";
print"<iframe id='codepress' name='codepress' src='../../../extras/codepress/codepress.php?action=edit&file=$path/$filename&language=$resto' width='98%' height='400'></iframe>";
} else {
    print "<form action='$base_url&amp;output=edit&amp;save=true' method='post'>";
    print "<textarea cols=120 rows=20 name='text'>";
    print htmlentities(fread($fp, filesize($home_directory.$path.$filename)));
    fclose ($fp);
    print "</textarea>";
}
    print "<br /><br />";
    print "$StrFilename <input size=40 name='filename' value=\"".htmlentities($filename)."\">";
    print "<br /><br />";
   print "<input class='bigbutton' type='reset' value='$StrRestoreOriginal'>&nbsp;<input class='bigbutton' type='submit' value='$StrSaveAndExit' onClick='myfile.value = CodePress.getCode();'>";
   print "<input type='hidden' name='path' value=\"".htmlentities($path)."\">";
   print "</form>";
   }
   else
    print "<font color='#CC0000'>$StrErrorOpeningFile</font>";
   print "<br /><br /></center>";
   print "</td>";
  print "</tr>";
 print "</table>";
 print "</div>";


echo   "<div class='tab-page' id='FCKtab'>";
echo      "<h2 class='tab' id='FCKcode'>V-Form</h2>";

if (file_exists("../../../extras/FCKeditor/fckeditor.php")){
  include("../../../extras/FCKeditor/fckeditor.php");

  $sBasePath ="../../../extras/FCKeditor/" ;

  $oFCKeditor = new FCKeditor('editor') ;
  $oFCKeditor->BasePath	= $sBasePath;
  $oFCKeditor->Height= 400;
  $oFCKeditor->Value	= @join(@file($file));
  $oFCKeditor->Create() ;
}
else{
    echo   "Necessario FCKeditor per Creazione Form Visuali !!!<br>";
    echo   "Effettuare il Download dal sito web di riferimento e<br>";
    echo   "aggiungerlo dopo averlo scompattato nella cartella extras oppure<br>";
    echo   "scaricarlo tramite pannello admin alla voce php-synaptic.<br>";
}

echo "</div>";
 echo "</div>";


}
else
 print "<font color='#CC0000'>$StrAccessDenied</font>";
?>

